Crate below_derive

source ·

Derive Macros§

  • Implements std::str::FromStr for enum, which has same constraints as EnumToString and works in the opposite direction.
  • Implements std::string::ToString for enum, which must only contain unit variants or variants with single unnamed field, e.g. Some(T). Unit variants are converted to their snake case representations. Nested variants works similarly by joining the variant name and field representation with dot “.”. For example, None => “none”, and Some(None) => “some.none”.
  • Implements the Queriable trait for a model. An enum with variants that map to its fields are created with auto derive above: EnumToString, EnumFromStr. That enum is used as Queriable::FieldId. Subquery fields are accessed by delegating the subquery field_id to the corresponding sub-models.